#include<queue>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

const int inf = 0x3f3f3f3f;
int a[505][505];
bool vis[505];
int dis[505];
int cnt[505];

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		memset(vis, 0, sizeof vis);
		memset(cnt, 0, sizeof cnt);
		memset(a, 0x3f, sizeof a);
		memset(dis, 0x3f, sizeof dis);
		
		int n, m, w;
		cin>>n>>m>>w;
		
		for(int i = 1;i <= m;i++)
		{
			int x, y, z;
			cin>>x>>y>>z;
			a[x][y] = a[y][x] = min(a[x][y], z);
		}
		
		for(int i = 1;i <= w;i++)
		{
			int x, y, z;
			cin>>x>>y>>z;
			a[x][y] = -z;
		}
		
		queue<int> q;
		q.push(1);
		dis[1] = 0;
		int flag = 0;
		
		while(!q.empty())
		{
			if(flag)
				break;
			
			int t = q.front();
			q.pop();
			vis[t] = 0;
			
			for(int i = 1;i <= n;i++)
			{
				if(dis[t]+a[t][i] < dis[i])
				{
					dis[i] = dis[t]+a[t][i];
					if(!vis[i])
					{
						q.push(i);
						vis[i] = 1;
						cnt[i]++;
						if(cnt[i] > n)
						{
							flag = 1;
							break;
						}
					}
				}
					
			}
		}
		
		if(flag)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl; 
	}
	cout<<endl;
	system("pause");
	return 0;
}

